package com.szsfm.vehiclemanagement.mvp.presenter;

import com.szsfm.vehiclemanagement.bean.Message;
import com.szsfm.vehiclemanagement.mvp.model.IMessageModel;
import com.szsfm.vehiclemanagement.mvp.model.modelImpl.MessageModelImpl;
import com.szsfm.vehiclemanagement.mvp.view.IMessageView;

import java.util.List;

/**
 * Created by zhoubigbo on 2017/11/29.
 */

public class MessagePresenter {

    IMessageModel model;
    IMessageView view;

    public MessagePresenter(IMessageView view) {
        this.view = view;
        model = new MessageModelImpl();
    }

    public void getMessage() {
        if (view != null) {
            view.startLoadData();
        }
        if (model != null) {
            model.requestMessages(messageCallback);
        }

    }

    IMessageModel.MessageCallback messageCallback = new IMessageModel.MessageCallback() {

        @Override
        public void messages(List<Message> messages) {
            if (view != null) {
                view.loadDataFinish(messages);
            }
        }
    };

}
